package tvv.levelup.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tvv.levelup.dao.IPetEquipmentDao;
import tvv.levelup.dao.PetEquipmentDao;
import tvv.levelup.models.Pet;

import java.util.Iterator;
import java.util.List;

/**
 * Created by VLAD on 03.09.2014.
 */
@Service
public class PetEquipmentService implements IPetEquipmentService {

    @Autowired
    private IPetEquipmentDao petEquipmentDao;

    @Override
    public List<Integer> getPetEquipments(Pet pet) {
        return petEquipmentDao.getPetEquipments(pet);
    }

    @Override
    public void savePetEquipment(Pet pet) {
        Iterator<Integer> iter = pet.getEquipment().iterator();
        while (iter.hasNext())
        {
            petEquipmentDao.savePetEquipment(pet.getId(), iter.next());

        }

    }

    @Override
    public void deletePetEquipment(Pet pet) {
        petEquipmentDao.deletePetEquipment(pet);

    }
}
